package com.lzh.edu.controller;


import com.lzh.commonutils.CommonResult;
import com.lzh.edu.service.SubjectService;
import com.lzh.edu.vo.subject.SubjectNestVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author lizuhu
 * @since 2021-04-23
 */
@CrossOrigin
@RestController
@RequestMapping("/edu/subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    @ApiOperation(value = "excel表批量导入课程")
    @PostMapping("/addSubject")
    public CommonResult addSubject(MultipartFile file) {
        subjectService.saveSubject(file);
        return CommonResult.ok();
    }

    @ApiOperation(value = "获取课程分类列表")
    @GetMapping("/getSubject")
    public CommonResult nestSubject() {
        List<SubjectNestVo> subjectList = subjectService.nestList();
        return CommonResult.ok().data("items",subjectList);
    }
    
}

